import { defineStore } from 'pinia'
import { ref } from 'vue'

const initState = {
  startDate: '',
  endDate: '',
  cityName: '大理',
  searchText: '',
}

export const useHotelSearch = defineStore(
  'hotelSearch',
  () => {
    const searchInfo = ref({ ...initState })

    const setSearchInfo = (val) => {
      searchInfo.value = Object.assign(searchInfo.value, val)
    }

    const clearSearchInfo = () => {
      searchInfo.value = { ...initState }
    }

    return {
      searchInfo,
      setSearchInfo,
      clearSearchInfo,
    }
  },
  {
    persist: true,
  },
)
